/*
Realistic Unit Modification v4.0 Dialog 
v4.0.0.1 [ALPHA]
Concept & Development by Draper & Raps | [VRC]
*/
ROEzone = {

private ["_bool","_target","_boolarry","_marker","_shape","_a","_b","_mx","_my","_dir","_x","_y","_xprime","_yprime","_reldir","_xbor","_ybor","_targetprime","_F","_corr","_foci1","_foci2"];

_bool = true;
_target = _this select 0;
_boolarry = [];
for [{_n = 0},{_n < (count RUM_ROE_nofire)},{_n = _n + 1}] do {
	_marker = RUM_ROE_nofire select _n;
	_shape = markerShape _marker;
	_a = getMarkerSize _marker select 0;
	_b = getMarkerSize _marker select 1;
	_mx = getMarkerPos _marker select 0;
	_my = getMarkerPos _marker select 1;
	_dir = markerDir _marker;
	_x = _target select 0;
	_y = _target select 1;

	switch (_shape) do {
		case "RECTANGLE": {
			_xprime =_x -_mx;
			_yprime =_y -_my;
			_reldir = 0;
			if (_yprime == 0) then {
				_reldir = 0;
			} else {
				_reldir = atan (_xprime/_yprime) - _dir;
				if (_reldir < 0) then {_reldir = _reldir + 360};
			};
			_xbor = abs(_a/sin(_reldir));
			_ybor = abs(_b/cos(_reldir));
			if ((sqrt(_xprime ^2 + _yprime ^2)) < (_xbor min _ybor)) then {
				_bool = false;
			};
		};
		case "ELLIPSE": {
			_targetprime = [_x,_y];
			_F = sqrt(abs(_a ^2 - _b ^2));
			_corr = 90;
			if (_a < _b) then {
				_corr = 0;
			};
			_foci1 = [(_F * sin(_dir + _corr) + _mx),(_F * cos(_dir + _corr) + _my)];
			_foci2 = [(-_F * sin(_dir + _corr) + _mx),(-_F * cos(_dir + _corr) + _my)];
			if (((_targetprime distance _foci1) + (_targetprime distance _foci2))<(2 * (_a max _b))) then {
				_bool = false;
			};
		};
		default{};
	};
};

if !(_bool) then {
	hint "Proposed target is in a restricted zone. Select another target.";
};

_bool; 
};